package com.yy.xshell.core;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author wxy
 * @version 1.0
 * @date 2024/12/3 10:21
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ShellContext implements Serializable {

    private String key;

    private String msg;

    private String clear;

    private String mode;

    private String insertStr;

    @JSONField(serialize = false)
    private Environment environment;

    public ShellContext(String msg, String key, Environment environment){
        this.msg = msg;
        this.mode = Mode.NORMAL.toString();
        this.key = key;
        this.environment = environment;
    }

    public String toJsonString(){
        return JSONObject.toJSONString(this, JSONWriter.Feature.IgnoreEmpty);
    }

    public enum Mode {
        //常规
        NORMAL,
        //私有模式
        PRIVATE;
    }

    @Data
    public static class Environment{

        //字体大小
        private int fontSize;
    }
}
